# -*- coding:utf-8 -*-
from google.appengine.api import users
from django import template
from blog.models import *

register = template.Library()

class BlogInit(template.Node):
    def __init__(self):
        pass
    
    def render(self,context):
        context['env_blog'] = Blog.get_or_insert('blog')
        context['env_author'] = Author.get_or_insert('author')
        context['env_is_admin'] = users.is_current_user_admin()
        context['env_tags'] = Tag.all()
        return ''

@register.tag(name='blog_init')
def blog(parser,token):
    return BlogInit()
